<?php ob_start() ?>

<div class="row">
    <?php if (isset($_SESSION['adminbetporra_msj'])) { ?>
        <div class="alert alert-success alert-dismissable col-lg-12 text-center">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            <strong><?php echo $_SESSION['adminbetporra_msj'] ?></strong>
        </div>
        <?php
        unset($_SESSION['adminbetporra_msj']);
    }
    ?>
    <div class="col-lg-12">
        <h1>Porras <small>Datos Porra</small></h1>
    </div>
</div>
<hr>
<div class="row">
    <div class="col-lg-12">
        <a class="btn btn-primary" href="modificar_porra/<?php echo $_GET['id'] ?>"><i class="fa fa-plus-circle"></i> Modificar Porra</a>
        <a class="btn btn-primary" href="comprobar_porra/<?php echo $_GET['id'] ?>"><i class="fa fa-plus-circle"></i> Comprobar Porra</a>
        <a class="btn btn-primary" href="repartir_bote/<?php echo $_GET['id'] ?>"><i class="fa fa-plus-circle"></i> Repartir bote</a>
        <hr>

        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-archive"></i> Datos de la porra</h3>
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-bordered table-striped table-hover">
                        <tbody>
                            <tr>
                                <th>Fecha Inicio</th>
                                <td><?php echo date("d-m-Y H:i", strtotime($params['fecha_inicio'])); ?></td>
                            </tr>
                            <tr>
                                <th>Fecha Fin</th>
                                <td><?php echo date("d-m-Y H:i", strtotime($params['fecha_fin'])); ?></td>
                            </tr>
                            <tr>
                                <th>Bote Porra</th>
                                <td><?php echo $params['bote_porra'] ?> bp</td>
                            </tr>
                            <tr>
                                <th>Puntos Apuestas</th>
                                <td><?php echo $params['puntos_apuesta'] ?> bp</td>
                            </tr>
                            <tr>
                                <th>Disponible</th>
                                <td><?php echo $params['disponible'] ?></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-suitcase"></i> Partidos</h3>
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-bordered table-hover table-striped tablesorter" id="dataTables-example">
                        <thead>
                            <tr>
                                <th>Fecha <i class="fa fa-sort"></i></th>
                                <th>Local <i class="fa fa-sort"></i></th>
                                <th>Visitante <i class="fa fa-sort"></i></th>
                                <th>Goles local <i class="fa fa-sort"></i></th>
                                <th>Goles visitante <i class="fa fa-sort"></i></th>
                                <th>Estado <i class="fa fa-sort"></i></th>
                                <th>Acciones</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($params['partidos'] as $fila) { ?>
                                <tr>
                                    <td><?php echo date("d-m-Y H:i", strtotime($fila['fecha'])); ?></td>
                                    <td><a href="ver_equipo/<?php echo $fila['equipo_local'] ?>"><?php echo $fila['equipo_local_nombre'] ?></a></td>
                                    <td><a href="ver_equipo/<?php echo $fila['equipo_visitante'] ?>"><?php echo $fila['equipo_visitante_nombre'] ?></a></td>
                                    <td><?php echo $fila['goles_local'] ?></td>
                                    <td><?php echo $fila['goles_visitante'] ?></td>
                                    <td><?php echo $fila['estado'] ?></td>
                                    <td align="center">
                                        <a href="ver_partido/<?php echo $fila['id'] ?>"><i class="fa fa-search" title="Ver"></i></a>
                                    </td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-suitcase"></i> Pronosticos</h3>
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-bordered table-hover table-striped tablesorter" id="data-table-pronosticos">
                        <thead>
                            <tr>
                                <th>Fecha <i class="fa fa-sort"></i></th>
                                <th>Partido <i class="fa fa-sort"></i></th>
                                <th>Goles local <i class="fa fa-sort"></i></th>
                                <th>Goles visitante <i class="fa fa-sort"></i></th>
                                <th>Estado <i class="fa fa-sort"></i></th>
                                <th>Usuario <i class="fa fa-sort"></i></th>
                                <th>Acciones</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($params2 as $fila) { ?>
                                <tr
                                <?php
                                if ($fila['acertada'] == "Acertada") {
                                    echo "class='success'";
                                } else if ($fila['acertada'] == "Perdida") {
                                    echo "class='danger'";
                                }
                                ?> 
                                    >
                                    <td><?php echo $fila['fecha']; ?></td>
                                    <td><a href="ver_partido/<?php echo $fila['partido']; ?>" title="Ver Partido"><?php echo $fila['partidos']['equipolocalnombre'] ?> - <?php echo $fila['partidos']['equipovisitantenombre'] ?></a></td>
                                    <td><?php echo $fila['goles_local'] ?></td>
                                    <td><?php echo $fila['goles_visitante'] ?></td>
                                    <td><?php echo $fila['acertada'] ?></td>
                                    <td><a href="ver_usuario/<?php echo $fila['usuario']; ?>"><?php echo $fila['nombreusuario'] ?></a></td>
                                    <td align="center">
                                        <a href="ver_pronostico/<?php echo $fila['id'] ?>"><i class="fa fa-search" title="Ver"></i></a>
                                        <a href="eliminar_partido/<?php echo $fila['id'] ?>"><i class="fa fa-trash-o" title="Eliminar"></i></a>
                                    </td>
                                </tr>
<?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <hr>
        <a class="btn btn-primary" href="modificar_porra/<?php echo $_GET['id'] ?>"><i class="fa fa-plus-circle"></i> Modificar Porra</a>
        <hr>
    </div>
    <script>
        $(document).ready(function() {
            $('#data-table-pronosticos').dataTable({
                "order": [[0, "desc"], [1, "asc"]]
            });
        });

    </script>

    <?php
    $contenido = ob_get_clean();
    include "app/templates/template_admin.php";
    ?>